<!--
  - Copyright (c) 2018.
  - 北京九思金信科技有限公司对该文件内容保留所有权利。
  - 未经许可，不得私自拷贝、传播、发布、引用该文件内容，违者将被追究法律责任。
  -->
  <template>
  <div class="PaymentSearch_box">
    <div class="PaymentSearch_title">
      <div class="search_box">
        <img
          src="@/pages/mobile/assets/img/Back@3x.png"
          @click="returnHistoy"
          alt
        />
        <input
          type="text"
          placeholder="搜索报价测算名称"
          maxlength="20"
          v-model="searchInfo"
        />
      </div>
      <i @click="returnHistoy">取消</i>
    </div>
    <!-- 内容 -->
    <scroll class="PaymentSearch_scroll">
<div
          class="customerManagement_content_item"
          v-for="item in searchlist"
          :key="item.id"
          @click="itemClick(item)"
          :class="
            item.customerType.label == '个人'
              ? 'customerManagement_content_item_gr'
              : 'customerManagement_content_item_qy'
          "
        >
          <div class="header_item_img">
            <i v-if="item.customerType.label == '个人'">个人</i>
            <i v-else>企业</i>
          </div>
          <h3>{{ item.customerName }}</h3>
          <p class="qy_title">社会统一信用码：</p>
          <p class="gr_title">身份证：</p>
          <em>{{ item.identityNo }}</em>
          <span>有限责任公司</span>
          <div class="footer__item_img"></div>
        </div>
    </scroll>
    <div
      v-if="!searchlist.length && searchInfo"
      class="PaymentSearch_none_list"
    >
      没有搜索到任何关于“{{ searchInfo }}”的客户
    </div>
    <div
      v-show="!searchlist.length && !searchInfo"
      class="PaymentSearch_none_list"
    >
      搜索客户
    </div>

    <!-- 弹框 -->
    <transition name="fade">
      <div
        v-if="paymentPopoutState"
        class="cache_popout"
        ref="cachePopout"
        :class="{ cache_popout_active: paymentPopoutState }"
      >
        <div class="cache_popout_info">
          <span>请确认是否收取该单据</span>
          <div class="btn">
            <em @click="PaymentCancel">取消</em>
            <em @click="Paymentrequest(verifyOperationId)">确定</em>
          </div>
        </div>
      </div>
    </transition>
      <cm-detail
        ref="edit"
        class="cmdetail_b"
        :childDataType="itemDataType"
        @childReturnHistiy="shutItemDataInfo"
        v-if="CmDetail"
      ></cm-detail>
  </div>
</template>
  
  <script>
import Scroll from "@/pages/mobile/assets/js/JoysScroll/JoysScroll";
import CmDetail from "./CmDetail.vue";
import { myDOM } from "@/pages/mobile/assets/js/utils.js";
export default {
  name: "QuoteCalculateSearch",
  components: {
    Scroll,
    CmDetail
  },
  data () {
    return {
      searchInfo: "",
      CmDetail: false, //详情组件
      searchlist: [],
      paymentPopoutState: false,
      verifyOperationId: "", //正在核销id
    };
  },
  methods: {
    // 关闭详情页面信息
    shutItemDataInfo () {
      this.CmDetail = false;
    },
    itemClick (val) {
      console.log(val, '试试')
      this.itemDataType = val.customerType.label;
      this.CmDetail = true;
      setTimeout(() => {
        this.$refs.edit.itemQueryData(val.customerType.label, val.customerId);
      }, 10);
    },
    paymentEvent (id) {
      this.verifyOperationId = id
      this.paymentPopoutState = true
    },
    PaymentCancel () {
      this.paymentPopoutState = false
    },

    loadData () {
      console.log('一次')
      this.$axios({
        method: "post",
        url: "/joys-rest/lss-customer/custInfo/list",
        headers: {
          "AUTH-TOKEN": localStorage.getItem("AUTH-TOKEN"),
          "Content-Type": "application/json;charset=UTF-8"
        },
        params: {
          pageIndex: 1,
          pageSize: 1000
          // filter: ""
        },
        data: {
          ininQuery:false,
          filter: this.searchInfo
        }
      })
        .then(res => {
          console.log(res, "hhhhhhhhhhhhhhhhhhhhhhhhh");
          this.searchlist = res.data.rows
        })
        .catch(error => {
          console.log(error, "搜索失败");
        });
    },
    returnHistoy () {
      this.$router.goBack();
    }
  },
  created () {
    // 节流
    this.$watch(
      "searchInfo",
      myDOM.debounce(newQuery => {
        this.loadData();
      }, 300)
    );
  }
};
</script>
  
  <style scoped lang="less">
.PaymentSearch_box {
  position: fixed;
  top: 0rem;
  bottom: 0.1rem;
  width: 100%;
  height: 100%;
  z-index: 300;
  background: #ffffff;
  .PaymentSearch_title {
    height: 0.44rem;
    width: 100%;
    background: #ffffff;
    box-shadow: inset 0 -1px 0 0 rgba(207, 207, 207, 0.2);
    position: relative;
    overflow: hidden;
    .search_box {
      position: absolute;
      top: 0rem;
      left: 0rem;
      width: 100%;
      line-height: 0.44rem;
      height: 0.44rem;
      img {
        width: 0.2rem;
        position: absolute;
        // left: 0.085rem;
        // top: 0.12rem;
        top: 0rem;
        left: 0rem;
        padding: 0.12rem 0.085rem;
      }
      input {
        padding-left: 0.1rem;
        height: 0.32rem;
        background: rgba(141, 141, 141, 0.05);
        font-family: Regular;
        font-size: 0.14rem;
        color: #001616;
        letter-spacing: -0.34px;
        line-height: 0.14rem;
        margin-top: -0.05rem;
        margin-left: 0.36rem;
        width: 100%;
      }
      input::placeholder {
        font-family: Regular;
        font-size: 0.14rem;
        color: #c6c6c6;
        letter-spacing: -0.34px;
        line-height: 0.14rem;
      }
    }
    i {
      display: block;
      height: 0.43rem;
      width: 0.63rem;
      line-height: 0.44rem;
      text-align: center;
      font-family: Regular;
      font-size: 0.14rem;
      color: #001616;
      letter-spacing: -0.34px;
      position: absolute;
      top: 0rem;
      right: 0rem;
      background: #ffffff;
    }
  }

  .PaymentSearch_scroll {
    overflow: hidden;
    top: 0.44rem;
    .customerManagement_content_item {
      margin: 0.1rem 0.16rem 0rem 0.16rem;
      background: #ffffff;
      box-shadow: 0 2px 0.07rem 0 rgba(0, 0, 0, 0.06);
      border-radius: 0.05rem;
      padding-left: 0.12rem;
      overflow: hidden;
      padding-top: 0.24rem;
      position: relative;
      height: 1.1rem;
      h3 {
        margin-top: 0.08rem;
        font-family: PingFangSC-Medium;
        font-size: 0.16rem;
        color: #3e3e3e;
        letter-spacing: 0;
        font-weight: 700;
        margin-bottom: 0.04rem;
        height: 0.21rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        width: 70%;
      }
      p {
        font-family: PingFangSC-Regular;
        font-size: 0.12rem;
        color: #706967;
        letter-spacing: 0;
        margin-bottom: 0.04rem;
        opacity: 0.65;
        height: 0.17rem;
      }
      em {
        display: block;
        font-family: PingFangSC-Regular;
        font-size: 0.14rem;
        color: #706967;
        letter-spacing: 0;
        height: 0.2rem;
        line-height: 0.2rem;
        opacity: 0.65;
        height: 0.2rem;
      }
      span {
        font-family: PingFangSC-Regular;
        font-size: 0.12rem;
        color: #9c9795;
        letter-spacing: 0;
        display: block;
        position: absolute;
        bottom: 0.12rem;
        opacity: 0.65;
        left: 0.05rem;
        // transform: scale(0.84);
        display: none;
      }
      .footer__item_img {
        background-size: 100% 100%;
        position: absolute;
        bottom: 0px;
        right: 0px;
        width: 0.78rem;
        height: 0.9rem;
      }
      .header_item_img {
        margin-top: -0.24rem;
        margin-left: -0.12rem;
        width: 0.4rem;
        height: 0.18rem;
        overflow: hidden;
        border-bottom-right-radius: 5px;
        i {
          display: block;
          font-family: PingFangSC-Regular;
          font-size: 0.12rem;
          color: #ffffff;
          letter-spacing: 0;
          line-height: 0.18rem;
          box-sizing: border-box;
          // transform: scale(0.84);
          text-align: center;
        }
      }
      .qy_title {
        display: none;
      }
      .gr_title {
        display: none;
      }
    }
    .font_box {
      height: 0.9rem;
      display: block;
    }
    .customerManagement_content_item_qy {
      background-size: 50%;
      .header_item_img {
        background: #4555a0;
      }
      span {
        display: block;
      }
      .qy_title {
        display: block;
      }
      .footer__item_img {
        background: #ffffff
          url("./../../assets/img/KX_enterprise_qy.png")
          no-repeat center center;
        background-size: 100% 100%;
      }
    }
    .customerManagement_content_item_gr {
      background-size: 50%;
      .header_item_img {
        background: #e5a83f;
      }
      .gr_title {
        display: block;
      }
      .footer__item_img {
        background: #ffffff
          url("./../../assets/img/KX_enterprise_gr.png")
          no-repeat center center;
        background-size: 100% 100%;
      }
    }
  }
  .PaymentSearch_none_list {
    font-family: Regular;
    font-size: 0.13rem;
    color: rgba(0, 22, 22, 0.8);
    letter-spacing: 0;
    text-align: center;
    margin-top: 30%;
  }

  // 弹窗
  .cache_popout {
    z-index: 309;
    width: 100%;
    height: 100%;
    background-size: 100% 100%;
    background: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.35);
    position: fixed !important; /* 浮动对话框 */
    position: absolute;
    top: 0%;
    left: 0%;
    display: block;
    transform: scale(1);
    .cache_popout_info {
      border-radius: 0.05rem;
      height: 1.31rem;
      width: 80%;
      position: fixed !important; /* 浮动对话框 */
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: 5;
      border-radius: 0.05rem;
      font-size: 0.17rem;
      line-height: 0.2rem;
      color: #414244;
      letter-spacing: 0;
      background: rgba(248, 248, 248, 1);
      border-radius: 0.14rem;
      background: #ffffff;
      border-radius: 4px;
      overflow: hidden;
      span {
        font-family: Semibold;
        display: block;
        font-weight: 700;
        margin: 0.3rem 0;
        font-size: 0.17rem;
        color: #000000;
        letter-spacing: -0.41px;
        text-align: center;
        line-height: 0.22rem;
        font-family: PingFangSC-Regular;
        font-size: 20px;
        color: #111a34;
        letter-spacing: -0.48px;
        text-align: center;
        line-height: 20px;
      }
      .btn::before {
        background: #3f3f3f;
        background: rgba(0, 0, 80, 0.05);
        height: 1px;
        content: "";
        width: 100%;
        display: block;
      }
      .btn {
        font-family: Semibold;
        margin-top: 0.18rem;
        width: 100%;
        height: 0.43rem;
        line-height: 0.43rem;
        background-size: 100% 100%;
        em {
          width: 50%;
          float: left;
          height: 0.43rem;
          line-height: 0.43rem;
          padding-top: 0.1rem;
          font-size: 0.18rem;
          color: #0e0e0e;
          letter-spacing: -0.41px;
          line-height: 0.22rem;
          margin-right: -1px;
          font-family: PingFangSC-Medium;
          color: #265ca7;
          text-align: center;
          font-weight: 700;
        }
        em:nth-child(1) {
          border-right: 1px rgba(0, 0, 80, 0.05) solid;
          color: #666f83;
        }
      }
    }
  }

  .fade-enter-active {
    transition: all 0.3s ease;
  }
  .fade-leave-active {
    transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
  }
  .fade-enter, .fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
    transform: scale(1.4) 0.3s;
    opacity: 0;
  }
}
</style>
